<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Carbon;

class UserWorkshopApply extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'UserWorkshopApply:timeout';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '申请查看二十四小时后无效';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        \App\model\UserWorkshopApply::where('created_at','<',Carbon::now()->addHours(-24))->chunk(100,function ($items){
            foreach ($items as $item){
                $item->status=1;
                $item->save();
                $this->info($item->id);
            }
        });
    }
}
